<?php
$con = mysql_connect("localhost","haschool_mdl1","B97C0HRYb7");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$db_selected = mysql_select_db("haschool_mdl1", $con);
if (!$db_selected) {
    die ('Can\'t use haschool_mdl1 : ' . mysql_error());
}  
$studentsids = $_GET[studentIds];

// Prepare the list of student ids:
$lastdeposityear='2011-2012';
$stdIdsArr = explode(",", $studentsids);

foreach ($stdIdsArr as $stdId) {
	if ($stdId!=null and $stdId!=''){
		
		$result = mysql_query("SELECT * FROM mdl_user_info_data where userid=$stdId and fieldid=10");
		$num_rows = mysql_num_rows($result);
		if ($num_rows==0){
			$sqldepositdata="insert into mdl_user_info_data (fieldid, userid, data)
						values(10, $stdId, '$lastdeposityear')";
			mysql_query($sqldepositdata);
		}else{
			$sqldepositdata="update mdl_user_info_data set data='$lastdeposityear' where userid=$stdId and fieldid=10";
			mysql_query($sqldepositdata);
		}
	}
}

mysql_close($con);

?>
<html>
<head>
<title>Horizon Academy Payment Status</title>
<script language=JavaScript>
window.close(); 
</script>
</head>
<body></body>
</html>
